﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using CrazyWorship1.Class_Files.Exceptions;

namespace CrazyWorship1.Class_Files
{
    public class DecodeSongFromWeb
    {
        private string _song;
        public DecodeSongFromWeb(string song)
        {
            _song=song;
        }
        public string SongTitle
        {
            get
            {
                string st = "";
                try
                {
                    
                    st= Regex.Match(_song, @"Details\W\W(?<title>[\w\f\n\t\v\x85\p{Z}]*)").Result("${title}").Trim();
                    
                }
                catch (Exception err)
                {
                    SendException.Send(err);
                }
                return st;
            }
        }
        public string Author
        {
            get
            {
                string st = "";
                try
                {

                    st = Regex.Match(_song, @"Author\w(?<author>[\w\f\n\t\v\x85\p{Z}]*)").Result("${author}").Trim();
                }
                catch (Exception err)
                {
                    SendException.Send(err);
                }
                return st;
            }
        }
        public string CopyWrite
        {
            get
            {
                string st = "";
                try
                {

                    st =Regex.Match(_song, @"Copyright(?<copywrite>[\w\f\n\t\v\x85\p{Z}]*)").Result("${copywrite}").Trim();
                }
                catch (Exception err)
                {
                    SendException.Send(err);
                }
                return st;
            }
        }
        public List<string> GetLyrics()
        {
            List<string> lyrics = new List<string>();
            try
            {

                int songStart = Regex.Matches(_song, @"Lyrics\W\W")[0].Index;
                string[] a = _song.Substring(songStart + 7).Split('\n');
                foreach (string st in a)
                {
                    string st2 = st.Replace("\r", "");
                    st2 = st2.Trim();
                    if (st2.Length != 0)
                        lyrics.Add(st2);

                }
            }
            catch (Exception err)
            {
                SendException.Send(err);
            }
            return lyrics;
        }

    }
}
